<template>
    <div id="paypal-button"></div>
</template>

<script setup>
import { onMounted } from 'vue'
onMounted(() => {
    console.log(111, paypal)
    paypal.Buttons({
        createOrder: function (data, actions) {
            // 创建订单
            return actions.order.create({
                purchase_units: [{
                    amount: {
                        value: '10.00' // 设置支付金额
                    }
                }]
            });
        },
        onApprove: function (data, actions) {
            // 支付成功回调
            return actions.order.capture().then(function (details) {
                // 处理支付成功逻辑
                console.log(details);
            });
        },
        onError: function (err) {
            // 支付失败回调
            console.log(err);
        }
    }).render('#paypal-button');
})
</script>

<style lang="scss" scoped></style>